package com.gxa.service.shezhiservice.Impl;

import com.gxa.common.R;
import com.gxa.mapper.shezhimapper.GongYingShangType46Mapper;
import com.gxa.pojo.GongYingShangType;
import com.gxa.service.shezhiservice.GongYingShangType46Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class GongYingShangType46ServiceImpl implements GongYingShangType46Service{

    @Autowired
    private GongYingShangType46Mapper GongYingShangType46Mapper;
    @Override
    public R selectAllGongYingShangTypeForPage(int page, int size) {
        R r = new R();
        int index = (page - 1)*size;
        List<GongYingShangType> GongYingShangTypes = GongYingShangType46Mapper.selectAllGongYingShangTypeForPage(index,size);
        if (GongYingShangTypes != null){
            r.setCode(200);
            r.setMsg("查询成功！");
            r.setData(GongYingShangTypes);
        }
        return r;
    }

    @Override
    public R selectGongYingShangTypeByType(int page, int size, String GongYingShangType) {
        R r = new R();
        int index = (page - 1)*size;
        List<GongYingShangType> GongYingShangTypes = GongYingShangType46Mapper.selectGongYingShangTypeByType(index,size,GongYingShangType);
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(GongYingShangTypes);
        return r;
    }

    @Override
    public R insertGongYingShangType(GongYingShangType GongYingShang) {
        R r = new R();
        int res =  GongYingShangType46Mapper.insertGongYingShangType(GongYingShang);
        r.setCode(500);
        r.setMsg("新增失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("新增成功");
        }
        return r;
    }

    @Override
    public R updateGongYingShangTypeById(GongYingShangType GongYingShang) {
        R r = new R();
        int res =  GongYingShangType46Mapper.updateGongYingShangTypeById(GongYingShang);
        r.setCode(500);
        r.setMsg("更新失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("更新成功");
        }
        return r;
    }

    @Override
    public R deleteGongYingShangTypeById(int id) {
        R r = new R();
        int res = GongYingShangType46Mapper.deleteGongYingShangTypeById(id);
        r.setCode(500);
        r.setMsg("删除失败");
        if(res>0)
        {
            r.setCode(200);
            r.setMsg("删除成功");
        }
        return r;
    }
}
